package com.ruoyi.dgdData.service.impl;

import java.util.List;
import java.util.concurrent.Future;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.calculate.BezierCurveUtil;
import com.ruoyi.dgdData.domain.plat.DataDgdJd;
import com.ruoyi.dgdData.domain.plat.DataDgdSd;
import com.ruoyi.dgdData.mapper.DataDgdJdMapper;
import com.ruoyi.dgdData.service.IDataDgdJdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;


/**
 * 单轨吊角度测试数据Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-28
 */
@Service
public class DataDgdJdServiceImpl implements IDataDgdJdService
{
    @Autowired(required = false)
    private DataDgdJdMapper dataDgdJdMapper;

    /**
     * 查询单轨吊角度测试数据
     * 
     * @param jdId 单轨吊角度测试数据主键
     * @return 单轨吊角度测试数据
     */
    @Override
    public DataDgdJd selectDataDgdJdByJdId(Long jdId)
    {
        return dataDgdJdMapper.selectDataDgdJdByJdId(jdId);
    }

    /**
     * 查询单轨吊角度测试数据
     *
     * @param dataTaskId
     * @return 单轨吊角度测试数据
     */
    @Override
    public Future<List<DataDgdJd>> selectDataDgdJdByDataTaskId(Long dataTaskId) {
        List<DataDgdJd> dataDgdJdEntities = dataDgdJdMapper.selectDataDgdJdByDataTaskId(dataTaskId);
        if (!dataDgdJdEntities.isEmpty()) {
            dataDgdJdEntities.forEach(item -> {
                if (item.getJiaoduList() != null) {
                    // 速度曲线数据
                    item.setJdChartLineDTO(BezierCurveUtil.calPoints(item.getJiaoduList(), 1f, true));
                }
            });
        }
        return new AsyncResult<>(dataDgdJdEntities);
    }

    /**
     * 查询单轨吊角度测试数据列表
     * 
     * @param dataDgdJd 单轨吊角度测试数据
     * @return 单轨吊角度测试数据
     */
    @Override
    public List<DataDgdJd> selectDataDgdJdList(DataDgdJd dataDgdJd)
    {
        return dataDgdJdMapper.selectDataDgdJdList(dataDgdJd);
    }

    /**
     * 新增单轨吊角度测试数据
     * 
     * @param dataDgdJd 单轨吊角度测试数据
     * @return 结果
     */
    @Override
    public int insertDataDgdJd(DataDgdJd dataDgdJd)
    {
        dataDgdJd.setCreateTime(DateUtils.getNowDate());
        return dataDgdJdMapper.insertDataDgdJd(dataDgdJd);
    }

    /**
     * 批量新增角度测试数据
     *
     * @param dataDgdJds
     */
    @Override
    public int batchDataDgdJd(List<DataDgdJd> dataDgdJds) {
        return dataDgdJdMapper.batchDataDgdJd(dataDgdJds);
    }

    /**
     * 修改单轨吊角度测试数据
     * 
     * @param dataDgdJd 单轨吊角度测试数据
     * @return 结果
     */
    @Override
    public int updateDataDgdJd(DataDgdJd dataDgdJd)
    {
        dataDgdJd.setUpdateTime(DateUtils.getNowDate());
        return dataDgdJdMapper.updateDataDgdJd(dataDgdJd);
    }

    /**
     * 变更单轨吊角度数据状态为2
     *
     * @param jdId
     * @return 结果
     */
    @Override
    public int updateDataDgdJdByJdId(Long jdId) {
        return dataDgdJdMapper.updateDataDgdJdByJdId(jdId);
    }

    /**
     * 变更单轨吊角度数据状态为2
     *
     * @param dataTaskId
     * @return 结果
     */
    @Override
    public int updateDataDgdJdByDataTaskId(Long dataTaskId) {
        return dataDgdJdMapper.updateDataDgdJdByDataTaskId(dataTaskId);
    }

    /**
     * 批量删除单轨吊角度测试数据
     * 
     * @param jdIds 需要删除的单轨吊角度测试数据主键
     * @return 结果
     */
    @Override
    public int deleteDataDgdJdByJdIds(Long[] jdIds)
    {
        return dataDgdJdMapper.deleteDataDgdJdByJdIds(jdIds);
    }

    /**
     * 删除单轨吊角度测试数据信息
     * 
     * @param jdId 单轨吊角度测试数据主键
     * @return 结果
     */
    @Override
    public int deleteDataDgdJdByJdId(Long jdId)
    {
        return dataDgdJdMapper.deleteDataDgdJdByJdId(jdId);
    }
}
